package com.rw.utils;

public class Page {

    private Integer size;
    private Integer offset;
    //表示的查询的结果有多少条数据
    private Integer count;
    //偏移量的计算公式： （页码（从1开始） -1）*size
    private Integer pageNum;

    public Page(Integer size, Integer pageNum) {
        this.size = size;
        if (pageNum < 1){
            pageNum = 1;
        }
        this.pageNum = pageNum;
        this.offset = (pageNum -1)* size;
    }

    public Integer getSize() {
        return size;
    }

    public void setSize(Integer size) {
        this.size = size;
    }

    public Integer getOffset() {
        return offset;
    }

    public void setOffset(Integer offset) {
        this.offset = offset;
    }

    public Integer getCount() {
        return count;
    }

    public void setCount(Integer count) {
        this.count = count;
    }

    public Integer getPageNum() {
        return pageNum;
    }

    public void setPageNum(Integer pageNum) {
        this.pageNum = pageNum;
    }

    @Override
    public String toString() {
        return "Page{" +
                "size=" + size +
                ", offset=" + offset +
                ", count=" + count +
                ", pageNum=" + pageNum +
                '}';
    }
}
